public class Solution1281 {
    public int subtractProductAndSum(int n) {
        String s=String.valueOf(n);
        int a=0,b=1;
        for (char c : s.toCharArray()) {
            a=a+c-'0';
            b=b*(c-'0');
        }
        return b-a;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1281().subtractProductAndSum(234));
    }
}
